package com.zerui.manager.app.accessrecord;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zerui.cola.dto.PageResponse;
import com.zerui.manager.app.accessrecord.executer.AccessRecordAddCmdExe;
import com.zerui.manager.app.accessrecord.executer.AccessRecordQryCmdExe;
import com.zerui.manager.web.AccessRecordService;
import com.zerui.manager.web.cmd.AccessRecordAddCmd;
import com.zerui.manager.web.cmd.AccessRecordQryCmd;
import com.zerui.manager.web.vo.AccessRecordVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author wh
 * @create_time 2023-08-23 11:08
 */
@Service
public class AccessRecordServiceImpl implements AccessRecordService {

    @Resource
    private AccessRecordQryCmdExe accessRecordQryCmdExe;

    @Resource
    private AccessRecordAddCmdExe accessRecordAddCmdExe;

    @Override
    public PageResponse<AccessRecordVO> getPageList(AccessRecordQryCmd accessRecordQryCmd) {
        Page<AccessRecordVO> accessRecordVoPage = accessRecordQryCmdExe.executePage(accessRecordQryCmd);
        return PageResponse.of(accessRecordVoPage.getRecords(),(int)accessRecordVoPage.getTotal(),
                (int) accessRecordVoPage.getSize(),
                (int) accessRecordVoPage.getCurrent());
    }

    @Override
    public void getAccessRecordListExport(AccessRecordQryCmd accessRecordQryCmd, HttpServletResponse response) {
        accessRecordQryCmdExe.execute(accessRecordQryCmd,response);
    }

    @Override
    public void addAccessRecord(AccessRecordAddCmd accessRecordAddCmd) {
	    accessRecordAddCmdExe.execute(accessRecordAddCmd);
    }
}
